package  
{
	import org.flixel.FlxGroup;
	import org.flixel.FlxSprite;
	import org.flixel.FlxText;
	import org.flixel.plugin.photonstorm.*;
	/**
	 * ...
	 * @author Billy Kaifer
	 */
	public class HUD extends FlxGroup
	{
		[Embed(source = "../media/165.png")]private var fontPNG:Class;
		
		private var lives:FlxBitmapFont;
		private var score:FlxBitmapFont;
		private var hpBar:FlxBar;
		private var specialBar:FlxSprite;
		private var hudBg:FlxSprite;
		
		public var level:FlxBitmapFont;
		public var liveUpdate:Boolean;
		
		public function HUD() 
		{
			hpBar = new FlxBar(5, 5, FlxBar.FILL_LEFT_TO_RIGHT, 100, 10, Registry.player, "health");
			hpBar.immovable = true;
			
			specialBar = new FlxSprite(2, 2);
			specialBar.makeGraphic(106, 16, 0xFFFF00FF);
			specialBar.immovable = true;
			
			hudBg = new FlxSprite(0, 0);
			hudBg.makeGraphic(600, 34, 0xFF000000);
			hudBg.immovable = true;
			
			level = new FlxBitmapFont(fontPNG, 8, 7, FlxBitmapFont.TEXT_SET1.substr(0, 67), 40, 0, 1);
			level.setText("LEVEL: " + Registry.currentLevel.toString());
			level.x = 5;
			level.y = 22;
			
			lives = new FlxBitmapFont(fontPNG, 8, 7, FlxBitmapFont.TEXT_SET1.substr(0, 67), 40, 0, 1);
			lives.setText("LIVES: " + Registry.player.lives.toString());
			lives.x = 100;
			lives.y = 22;
			
			score = new FlxBitmapFont(fontPNG, 8, 7, FlxBitmapFont.TEXT_SET1.substr(0, 67), 40, 0, 1);
			score.setText("SCORE: " + Registry.scoreThisLevel.toString());

			score.x = 115;
			score.y = 7;
			
			liveUpdate = true;
			
			add(hudBg);
			add(specialBar);
			add(hpBar);
			add(level);
			add(lives);
			add(score);
		}
		
		override public function update():void {
			super.update();
			
			if (liveUpdate) {
				lives.text = "LIVES: " + Registry.player.lives.toString();
				level.text = "LEVEL: " + Registry.currentLevel.toString();
				score.text = "SCORE: " + Registry.scoreThisLevel.toString();
			}
		}
		
		override public function destroy():void {
			trace("HUD Nuked!");
		}
		
	}

}